package com.nucarf.yc.app;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.nucarf.yc.bean.Order;

public class JsonToBean {

    public static void main(String[] args) {

        String json = "{\"database\":\"yidian_ceshi\",\"table\":\"tb_nc_member_order_info\",\"type\":\"insert\",\"ts\":1631070469,\"xid\":178047739,\"commit\":true,\"position\":\"mysql-bin.000339:14796697\",\"data\":{\"moi_id\":5853323,\"member_id\":215267}}";

        JSONObject jsonObject = JSON.parseObject(json);

        String table = jsonObject.getString("table");
        System.out.println(table);
        String data = jsonObject.getString("data");
        System.out.println(data);

        if("tb_nc_member_order_info".equals(table)) {

            Order order = JSON.parseObject(data, Order.class);
            System.out.println(order.toString());
        }

    }




}
